package com.woniu.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniu.entity.CreRemit;
import com.woniu.service.CreditRemitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 2022-9-27 10:22:49
 * 打款
 */
@Api("打款管理")
@RestController
@RequestMapping("/credit/remit")
public class CreditRemitController extends BaseController {

    @Autowired
    private CreditRemitService creditRemitService;

    /**
     * 查询列表
     */
    @ApiOperation("打款表查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "remitStatus", value = "打款状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "updateTime", value = "打款时间", dataType = "Date", dataTypeClass = Date.class)
    })
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody CreRemit creRemit) {
        startPage();
        List<CreRemit> list = creditRemitService.selectCreRemitList(creRemit);
        return getDataTable(list);
    }

    /**
     * 确认打款
     */
    @ApiOperation("打款操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "billId", value = "账单id", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int", dataTypeClass = Integer.class)
    })
    @GetMapping("/makeLoans/{orderId}/{billId}")
    public AjaxResult confirmPayment(@PathVariable int orderId, @PathVariable int billId) {
        return creditRemitService.remitOrderType(orderId, billId);
    }
}
